package com.email;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSenderImpl;

/**
 * @author 大忽悠
 * @create 2022/11/16 18:32
 */
@Configuration
@ConditionalOnProperty(prefix = "spring.mail", name = "host")
public class CommonEmailAutoConfig {

    @ConditionalOnMissingBean
    @Bean
    public CommonEmailService commonEmailService(JavaMailSenderImpl javaMailSender){
        return new CommonEmailService(javaMailSender);
    }
}
